//
// const.h
// Usage: const define for NewLife kernel
// Create Date: 2007-01-18
// Creator: MaJiuyue
//
#ifndef	_CONST_H_
#define	_CONST_H_

#define MAX_PROCESS_NR		32768		/* Max process number */
#define MAX_OPENFILE_NR		8		/* Max open file */
#define	GDT_SIZE		7		/* GDT Size */	
#define LDT_SIZE		3		/* LDT Size */
#define	IDT_SIZE		256		/* IDT Size */

// linear v.s. virtual address below 8M
#define lin2vir(lin) (lin - 0xC0000000)
#define vir2lin(vir) (vir + 0xC0000000)

// x86 page size
#define PAGE_SIZE	0x1000

// Privilege ring 
#define	PRIV_KNL	0		/* Privilege of Kernel */
#define	PRIV_DRV	1		/* Privilege of Driver */
#define PRIV_SRV	2		/* Privilege of Service */
#define	PRIV_USR	3		/* Privilege of User process */

// RPL
#define	RPL_KNL		SA_RPL0
#define RPL_DRV		SA_RPL1
#define	RPL_SVC		SA_RPL2
#define	RPL_USR		SA_RPL3

// Exception 
#define EXCEPTION_NR 20
#define VECTOR_PAGEFAULT	0xE

// Hardware interrupts
#define	IRQ_NR		16	/* Number of IRQs */
#define	CLOCK_IRQ	0
#define	KEYBOARD_IRQ	1
#define	CASCADE_IRQ	2	/* cascade enable for 2nd AT controller */
#define	ETHER_IRQ	3	/* default ethernet interrupt vector */
#define	SECONDARY_IRQ	3	/* RS232 interrupt vector for port 2 */
#define	RS232_IRQ	4	/* RS232 interrupt vector for port 1 */
#define	XT_WINI_IRQ	5	/* xt winchester */
#define	FLOPPY_IRQ	6	/* floppy disk */
#define	PRINTER_IRQ	7
#define RTC_IRQ		8
#define	AT_WINI_IRQ	14	/* at winchester */

/* clock frequency for timer in PC and AT */
#define TIMER_FREQ	1193182L    
/* clock freq, software setable */
#define HZ		100        

#endif

